<template name="overviews">
	<view style="margin-bottom: 100rpx;">
		<cu-custom bgColor="bg-gradual-pink" :isBack="false"><block slot="content">状态概览</block></cu-custom>
		<view v-for="(item, i) in dataRenderList" :key="i">
			<view class="cu-timeline" v-if="item.gas === 1">
				<view class="cu-item cur cuIcon-noticefill">
					<view class="content bg-green shadow-blur">
						<view class="cu-capsule radius">
							<view class="cu-tag bg-white">{{ item.createTime.split(' ')[0] }}</view>
							<view class="cu-tag line-white">{{ item.createTime.split(' ')[1] }}</view>
						</view>
						<p>
							<text>温度：{{ item.temperature }}°C</text>
							，
							<text>相对湿度：{{ item.humidity }}%</text>
						</p>
						<p>有害气体浓度：正常</p>
					</view>
				</view>
			</view>
			<view v-else class="cu-timeline">
				<view class="cu-item text-red cuIcon-attentionforbidfill">
					<view class="content bg-red shadow-blur">
						<view class="cu-capsule radius">
							<view class="cu-tag bg-white">{{ item.createTime.split(' ')[0] }}</view>
							<view class="cu-tag line-white">{{ item.createTime.split(' ')[1] }}</view>
						</view>
						<p>
							<text>温度：{{ item.temperature }}°C</text>
							，
							<text>相对湿度：{{ item.humidity }}%</text>
						</p>
						<p>有害气体浓度：超标</p>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			lastDataTime: 0,
			dataRenderList: []
		};
	},
	mounted() {
		this.selectAppData(new Date().getTime());
	},
	methods: {
		selectAppData(currTime) {
			setInterval(() => {
				uni.request({
					url: 'http:///106.13.136.240:12333/api/sensor/selectAppData',
					method: 'GET',
					data: {
						startTime: currTime
					},
					success: res => {
						try {
							this.dataRenderList = res.data.data;
						} catch (e) {
							console.log(JSON.stringify(e));
						}
					}
				});
			}, 3000);
		}
	}
};
</script>

<style></style>
